package com.ego.goodsweb.controller;

import com.ego.goodsweb.service.GoodsWebService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


import javax.annotation.Resource;
import java.util.Map;

@Controller
public class GoodsWebController {

    @Resource
    private GoodsWebService goodsWebService;

    @GetMapping("/item/{id}.html")
    public String item(@PathVariable("id") Long id, Model model) {
        //1.查询出模型数据
        Map<String,Object> modelMap = goodsWebService.loadModel(id);
        //2.将数据发送给视图
        model.addAllAttributes(modelMap);
        //3.并行生成静态页面
        //goodsWebService.createStaticHtml(id,modelMap);
        //4.渲染并响应
        return "item";
    }
}
